import { defineStore } from 'pinia'
import { getMenuInfo } from '@api/user'
import { useInfoStore } from './useUserStore'
import { IMenuType } from '@interface/user'
export const useMenuStore = defineStore('menuId', {
  state: (): {
    menu: IMenuType[]
  } => {
    return {
      menu: []
    }
  },
  getters: {},
  actions: {
    //获取用户菜单信息
    async getUserMenu() {
      let res = await getMenuInfo(useInfoStore().rolePerm)
      this.menu = res.data
      console.log('菜单信息', res)
    }
  },
  persist: {
    enabled: true, //开启数据存储
    strategies: [
      {
        storage: localStorage, //默认走session
        paths: ['menu'] //rolePerm持久化存储
      }
    ]
  }
})
